//
//  RejectViewController.m
//  EMMApp
//
//  Created by Mac on 16/5/10.
//  Copyright © 2016年 YiXun. All rights reserved.
//

#import "RejectViewController.h"

@interface RejectViewController ()<UITextViewDelegate>

@property (nonatomic, strong) UITextView *regectTextView;
@property (nonatomic, strong) UILabel *uilabel;

@end

@implementation RejectViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creatNavigationController];
    self.view.backgroundColor = [UIColor colorFromHexCode:@"#f7f7f7"];
    [self creatShowUI];
}

#pragma mark - 导航

- (void)creatNavigationController {
    [self updateNavBar];
    self.navigationItem.title = @"申请驳回";
    UIBarButtonItem *rightItme = [[UIBarButtonItem alloc] initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(rejectRightClick:)];
    [self.navigationItem setRightBarButtonItem:rightItme];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 导航右按钮
- (void)rejectRightClick:(UIButton *)btn {
    
}

#pragma mark - 界面初始化
- (void)creatShowUI {
    
    _regectTextView = [[UITextView alloc] initWithFrame:CGRectMake(15, 15, EMM_WIDTH-30, 220)];
    _regectTextView.layer.masksToBounds = YES;
    _regectTextView.layer.cornerRadius = 5;
    _regectTextView.delegate = self;
    _regectTextView.keyboardType = UIKeyboardTypeDefault;
    _regectTextView.returnKeyType = UIReturnKeyDone;
    _regectTextView.font = [UIFont systemFontOfSize:16];
    _regectTextView.layer.borderWidth = 1;
    _regectTextView.layer.borderColor = [[UIColor colorFromHexCode:@"#199595"] CGColor];

    [self.view addSubview:_regectTextView];
    _uilabel = [[UILabel alloc] initWithFrame:CGRectMake(18, 21, 200, 20)];
    _uilabel.text = @"请填写驳回原因";
    _uilabel.enabled = NO;//lable必须设置为不可用
    _uilabel.backgroundColor = [UIColor clearColor];
    [self.view addSubview:_uilabel];
}


-(void)textViewDidChange:(UITextView *)textView {
    if (self.regectTextView.text.length == 0) {
        _uilabel.text = @"请填写驳回原因";
    }else{
        _uilabel.text = @"";
    }
}


-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
    if ([text isEqualToString:@"\n"]) {
        [_regectTextView resignFirstResponder];
        return NO;
    }
    return YES;
}



@end
